﻿/*************************************************
* Title：TinyToolKit
* Author：Opportunity 
* Discribe：BillBoard的标签预制体需要添加BillBoardItem类，可以继承该类，修改TweenAnim方法
* CreateTime：2020-05-18 11:06:18
* Version：1.0
* Modify Recoder：
*************************************************/

using System;
using System.Runtime.CompilerServices;
using UnityEngine;
using UnityEngine.Events;

namespace TinyToolKit
{
    public class BillBoardItem : MonoBehaviour
    {
        private RectTransform rootTf;

        private void OnEnable()
        {
            rootTf = transform as RectTransform;
            gameObject.SetActive(true);
        }

        public void SetPosition(Vector3 localPos)
        {
            rootTf.localPosition = localPos; 
        }
        
        /// <summary>
        /// 标签出现和消失的动画
        /// </summary>
        /// <param name="isShow">显示还是隐藏</param>
        public virtual void TweenAnim(bool isShow)
        {
            gameObject.SetActive(isShow);
        }
        
        public virtual void OnSpawn(Transform spawnTf)
        {
            if (spawnTf != null)
                gameObject.name = spawnTf.name;
        }
    }
}
